-- -- 背景颜色主题
-- vim.o.background = 'dark'
-- -- utf8
-- vim.g.encoding = 'UTF-8'
-- vim.o.fileencoding = 'utf-8'
-- -- jkhl 移动时光标周围保留10行
-- vim.o.scrolloff = 10 -- 向下移动时
-- vim.o.sidescrolloff = 5 -- 向上移动时
-- -- 使用相对行号
-- vim.wo.number = true
-- vim.wo.relativenumber = true
-- -- 高亮所在行
-- vim.wo.cursorline = true
-- -- 显示左侧图标指示列
-- vim.wo.signcolumn = 'yes'
-- -- 右侧参考线，超过表示代码太长了，考虑换行
-- -- vim.wo.colorcolumn = "80"
-- -- 缩进2个空格等于一个Tab
-- vim.o.tabstop = 2
-- vim.bo.tabstop = 2
-- vim.o.softtabstop = 2
-- vim.o.shiftround = true
-- -- >> << 时移动长度
-- vim.o.shiftwidth = 2
-- vim.bo.shiftwidth = 2
-- -- 空格替代tab
-- vim.o.expandtab = true
-- vim.bo.expandtab = true
-- -- 新行对齐当前行
-- vim.o.autoindent = true
-- vim.bo.autoindent = true
-- vim.o.smartindent = true
-- -- 搜索大小写不敏感，除非包含大写
-- vim.o.ignorecase = true
-- vim.o.smartcase = true
-- -- 搜索高亮结果
-- vim.o.hlsearch = true
-- -- 边输入边搜索
-- vim.o.incsearch = true
-- -- 命令行高为2，提供足够的显示空间
-- vim.o.cmdheight = 2
-- -- 当文件被外部程序修改时，自动加载
-- vim.o.autoread = true
-- vim.bo.autoread = true
-- -- 允许折行
-- vim.wo.wrap = true
-- -- 光标在行首尾时<Left><Right>可以跳到下一行
-- vim.o.whichwrap = '<,>,[,]'
-- -- 允许隐藏被修改过的buffer
-- vim.o.hidden = true
-- -- 鼠标支持
-- vim.o.mouse = 'a'
-- -- 禁止创建备份文件
-- vim.o.backup = false
-- vim.o.writebackup = false
-- vim.o.swapfile = false
-- -- smaller updatetime
-- vim.o.updatetime = 300
-- -- 设置 timeoutlen 为等待键盘快捷键连击时间500毫秒，可根据需要设置
-- vim.o.timeout = true
-- vim.o.timeoutlen = 500
-- -- split window 从下边和右边出现
-- vim.o.splitbelow = true
-- vim.o.splitright = true
-- -- 自动补全不自动选中
-- vim.g.completeopt = 'menu,menuone,noselect,noinsert'
-- -- 样式
-- vim.o.background = 'dark'
-- vim.o.termguicolors = true
-- vim.opt.termguicolors = true
-- -- 补全增强
-- vim.o.wildmenu = true
-- -- Dont' pass messages to |ins-completin menu|
-- vim.o.shortmess = vim.o.shortmess .. 'c'
-- -- 补全最多显示10行
-- vim.o.pumheight = 10
-- -- 永远显示 tabline
-- vim.o.showtabline = 2
-- -- 使用增强状态栏插件后不再需要 vim 的模式提示
-- vim.o.showmode = false
-- -- 允许光标移动到没有文本的地方
-- vim.o.virtualedit = 'block'
-- -- 隐藏~符号
-- vim.wo.fillchars = 'eob: '
-- -- 自动进入打开文件的目录，可能与某些插件有冲突
-- -- vim.o.autochdir = true
-- -- 设置光标类型与宽度 ver50 代表宽度为字符宽度的50%，hor代表为字符高度的25%
-- vim.o.guicursor = 'n-v-c-sm:block,i-ci-ve:ver50,r-cr-o:hor25'
-- -- 显示不可见字符
-- vim.opt.list = true
-- vim.opt.listchars:append('space:⋅')
-- -- 取消自动注释，当前行是注释时，按下回车键会默认添加一行注释，这里取消这一行为
-- vim.opt.formatoptions:remove({ 'o', 'r', 'c' })

-- This file is automatically loaded by plugins.config
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '

local opt = vim.opt

opt.autowrite = true -- Enable auto write
opt.backup = false -- enable backup option
-- opt.clipboard = 'unnamedplus' -- Sync with system clipboard
opt.cmdheight = 2
opt.completeopt = 'menu,menuone,noselect'
opt.conceallevel = 3 -- Hide * markup for bold and italic
opt.confirm = true -- Confirm to save changes before exiting modified buffer
opt.cursorline = true -- Enable highlighting of the current line
opt.encoding = 'UTF-8'
opt.expandtab = true -- Use spaces instead of tabs
opt.formatoptions = 'jcroqlnt' -- tcqj
opt.grepformat = '%f:%l:%c:%m'
opt.grepprg = 'rg --vimgrep'
opt.ignorecase = true -- Ignore case
opt.inccommand = 'nosplit' -- preview incremental substitute
opt.laststatus = 0
opt.list = true -- Show some invisible characters (tabs...)
opt.listchars:append('space:⋅')
opt.mouse = 'a' -- Enable mouse mode
opt.number = true -- Print line number
opt.pumblend = 10 -- Popup blend
opt.pumheight = 10 -- Maximum number of entries in a popup
opt.relativenumber = true -- Relative line numbers
opt.scrolloff = 1 -- Lines of context
opt.sessionoptions = { 'buffers', 'curdir', 'tabpages', 'winsize' }
opt.shiftround = true -- Round indent
opt.shiftwidth = 2 -- Size of an indent
opt.shortmess:append({ W = true, I = true, c = true })
opt.showmode = false -- Dont show mode since we have a statusline
opt.sidescrolloff = 1 -- Columns of context
opt.signcolumn = 'yes' -- Always show the signcolumn, otherwise it would shift the text each time
opt.smartcase = true -- Don't ignore case with capitals
opt.smartindent = true -- Insert indents automatically
opt.spelllang = { 'en' }
opt.splitbelow = true -- Put new windows below current
opt.splitright = true -- Put new windows right of current
opt.swapfile = false -- Swap files are used to save the editing status of files when Vim editor crashes or is closed unexpectedly
opt.tabstop = 2 -- Number of spaces tabs count for
opt.termguicolors = true -- True color support
opt.timeout = true
opt.timeoutlen = 300
opt.undofile = true
opt.undolevels = 10000
opt.updatetime = 200 -- Save swap file and trigger CursorHold
opt.virtualedit = 'block' -- allow cursor move blank
opt.wildmode = 'longest:full,full' -- Command-line completion mode
opt.winminwidth = 5 -- Minimum window width
opt.whichwrap = '<,>,[,]'
opt.wrap = true -- ensable line wrap
opt.writebackup = false -- it first writes changes to the backup file, and then writes the changes to the original file.

if vim.fn.has('nvim-0.9.0') == 1 then
  opt.splitkeep = 'screen'
  opt.shortmess:append({ C = true })
end

-- Fix markdown indentation settings
vim.g.markdown_recommended_style = 0
